package EVM;

import Commons.Cell;

public class ZGate extends SimpleLogicGate {
    private int number;

    public ZGate(Cell input, Cell output, String name, int number) {
        super(input, output, name);
        this.number = number;
    }

    public void execute(boolean open) {
        if (open) {
            int mask = 0;
            for (int i = 0; i < 16; i++) {
                mask = (mask << 1) + 1;
            }
            if ((input.get() & mask) != 0) {
                output.setBit(number, false);
            } else {
                output.setBit(number, true);
            }
        }
    }

}
